//
//  MovieDetailView.m
//  SELF 豆瓣
//
//  Created by dllo on 15/11/1.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "MovieDetailView.h"
#import "AppTools.h"

//图片第三方
#import "UIImageView+WebCache.h"

//传值专用单例
#import "pass.h"

@interface MovieDetailView()

@end
@implementation MovieDetailView
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        [self createSubview];
        
    }
    
    return self;
    
}



-(void)createSubview
{
    self.movielcon = [[UIImageView alloc]initWithFrame:CGRectMake(30, 30, 120, 200)];
    //    [self.movielcon setImage:[UIImage imageNamed:@"/Users/dllo/Documents/UI/UI_敢死队/UI_敢死队/13994886463453412930.jpg"]];
    [self addSubview:self.movielcon];
    [self.movielcon release];
    self.rating = [[UILabel alloc]initWithFrame:CGRectMake(180, 30, 120, 20)];
    [self addSubview:self.rating];
    //    self.rating.backgroundColor = [UIColor redColor];
    [self.rating release];
    self.rating.text = @"评分:======";
    self.rating.font = [UIFont systemFontOfSize:16];
    self.rating.numberOfLines = 0;
    [self.rating sizeToFit];
    
    self.rating_count = [[UILabel alloc]initWithFrame:CGRectMake(260, 30, 140, 20)];
    [self addSubview:self.rating_count];
    [self.rating_count release];
    self.rating_count.text = @"评论           ";
    //    self.rating_count.backgroundColor = [UIColor redColor];
    self.rating_count.font = [UIFont systemFontOfSize:16];
    self.rating_count.numberOfLines = 0;
    [self.rating_count sizeToFit];
    
    
    
    self.date = [[UILabel alloc]initWithFrame:CGRectMake(180, 80, 150, 20)];
    [self addSubview:self.date];
    [self.date release];
    self.date.text = @"20140901==========";
    self.date.font = [UIFont systemFontOfSize:16];
    self.rating_count.numberOfLines = 0;
    [self.rating_count sizeToFit];
    
    self.runtime = [[UILabel alloc]initWithFrame:CGRectMake(180, 130, 150, 20)];
    [self addSubview:self.runtime];
    [self.runtime release];
    self.runtime.text = @"126min=========";
    self.runtime.font = [UIFont systemFontOfSize:16];
    self.runtime.numberOfLines = 0;
    [self.runtime sizeToFit];
    
    
    self.genres = [[UILabel alloc]initWithFrame:CGRectMake(180, 180, 200, 20)];
    [self addSubview:self.genres];
    [self.genres release];
    //    self.genres.backgroundColor = [UIColor redColor];
    self.genres.text = @"动作/冒险/惊悚======";
    self.genres.font = [UIFont systemFontOfSize:16];
    self.genres.numberOfLines = 0;
    [self.genres sizeToFit];
    
    self.country = [[UILabel alloc]initWithFrame:CGRectMake(180, 210, 100, 20)];
    [self addSubview:self.country];
    [self.country release];
    //    self.country.backgroundColor = [UIColor redColor];
    self.country.text = @"美国/法国=====";
    self.country.font = [UIFont systemFontOfSize:16];
    self.country.numberOfLines = 0;
    [self.country sizeToFit];
    
    
    self.title1 = [[UILabel alloc]initWithFrame:CGRectMake(30, 250, 100, 20)];
    [self addSubview:self.title1];
    [self.title1 release];
    self.title1.text = @"制作人";
    self.title1.font = [UIFont boldSystemFontOfSize:25];
    self.title1.numberOfLines = 0;
    [self.title1 sizeToFit];
    
    
    self.actors = [[UILabel alloc]initWithFrame:CGRectMake(30, 300, 325, 50)];
    [self addSubview:self.actors];
    [self.actors release];
    self.actors.text = @"稍等......                                    ======================================================================";
    self.actors.font = [UIFont systemFontOfSize:14];
    self.actors.numberOfLines = 0;
    [self.actors sizeToFit];
    
    self.title2 = [[UILabel alloc]initWithFrame:CGRectMake(30, 370, 100, 20)];
    [self addSubview:self.title2];
    [self.title2 release];
    self.title2.text = @"电影情节";
    self.title2.font = [UIFont boldSystemFontOfSize:25];
    self.title2.numberOfLines = 0;
    [self.title2 sizeToFit];
    
    
    
    self.plot = [[UILabel alloc]initWithFrame:CGRectMake(30, 410, 325, 350)];
    
    [self addSubview:self.plot];
    [self.plot release];
    //    self.plot.backgroundColor = [UIColor redColor];
    self.plot.text = @"稍等......                                    ====================================================================================================================================================================================================================================================================================================================================================================";
    self.plot.font = [UIFont systemFontOfSize:17];
    self.plot.numberOfLines = 0;
    [self.plot sizeToFit];
    
    
    
    NSString *str = [pass share].movieID;
    NSString *urlStr = [NSString stringWithFormat:@"http://project.lanou3g.com/teacher/yihuiyun/lanouproject/searchmovie.php?movieId=%@",str];
    [AppTools getDataWithURL:urlStr block:^(id result) {
        
        NSMutableDictionary *dic = result;
        
        NSMutableDictionary *resultDic = [dic objectForKeyedSubscript:@"result"];
        
        //传详情页的字典 收藏用
        [pass share].movieDtailDic = resultDic;
        //         NSLog(@"  \\\\\\\\\\\\\\\\\\\\\\%@",[pass share].movieDtailDic);
        NSURL *url = [NSURL URLWithString:[resultDic objectForKey:@"poster"]];
        //网络请求海报
        [self.movielcon sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeHoderImage"]];
        
        
        //评分
        NSString *rat = [resultDic objectForKey:@"rating"];
        NSString *rating = [NSString stringWithFormat:@"评分:%@",rat];
        self.rating.text = rating;
 
        
        
        //类型
        NSString *genres = [NSString stringWithFormat:@"类型:%@",[resultDic objectForKey:@"genres"]];
        self.genres.text = genres;
        
        //评论
        NSString *rating_count = [NSString stringWithFormat:@"评论:%@",[resultDic objectForKey:@"rating_count"]];
        self.rating_count.text = rating_count;
        
        self.plot.text = [resultDic objectForKey:@"plot_simple"];
        
        
        //国家
        NSString *country = [NSString stringWithFormat:@"国家:%@",[resultDic objectForKey:@"film_locations"]];
        self.country.text = country;
        self.actors.text = [resultDic objectForKey:@"actors"];
        
        
        //日期
        NSString *date = [NSString stringWithFormat:@"上映日期:%@",[resultDic objectForKey:@"release_date"]];
        self.date.text = date;
        
        
        //时长
        NSString *runtime = [NSString stringWithFormat:@"电影时长:%@",[resultDic objectForKey:@"runtime"]];
        self.runtime.text = runtime;
        
        
    }];
    
    
    
    
    
    
    
}

    

@end
